﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.ServiceProcess;
using System.Text;
using Wicresoft.Generic.Service.Properties;

namespace Wicresoft.Generic.Service
{
    static class GlobalFactory
    {
        public static IEnumerable<ServiceBase> GetAllServices()
        {
            foreach (var service in Settings.Default.Services)
            {
                string typeName = service.Split(',').First();
                string assemblyFile = service.Split(',').Last();
                var svrBase = Assembly.Load(assemblyFile).CreateInstance(typeName) as ServiceBase;
                yield return svrBase;
            }
        }
    }
}
